package org.pearl.springbootsecurity.demo.MP.data;

import lombok.extern.slf4j.Slf4j;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 内存存储
 */
@Slf4j
public class InMemoryDataScopeMetaStore {

    private static Map<String, DataScopeMapperProperty> cacheMap;

    /**
     * 初始化缓存
     */
    public static void initCacheMap() {
        cacheMap = new ConcurrentHashMap<>();
        if (log.isDebugEnabled()) {
            log.debug("InMemoryDataScopeMetaStore initialization succeeded");
        }
    }

    /**
     * 存储
     */
    public static void putCache(String key, DataScopeMapperProperty value) {
        cacheMap.put(key, value);
    }

    /**
     * 获取
     */
    public static DataScopeMapperProperty getCache(String key) {
        return cacheMap.get(key);
    }

}
